<?php

class User_FrontendController extends Zend_Controller_Action
{

    public function init()
    {
        $this->params = $this->getRequest()->getParams();
        System_Template::using("userinfo","Default");
        $this->model = new User_Model_User();
        parent::init();
    }

    public function indexAction()
    {
    }
    public function savecompanyinfoAction(){
        $id = $this->params['IDCOMPANY'];
        $arr = array(
            'name' => $this->params['NAME'],
            'email' => $this->params['EMAIL'],
            'address' => $this->params['DIACHI'],
            'phone' => $this->params['PHONE'],
            'website' => $this->params['WEBSITE'],
            'fax' => $this->params['FAX']
        );
        $table = new System_Table_Company();
        $table->update($arr,' id = '. (int)$id);
 		$this->_redirect('tour/index/orderlist');
        
    }
    public function saveAction()
    {
    	$db = Zend_Db_Table::getDefaultAdapter();
//     	cho truong hop cap nhat thong tin
    	if($this->params[flag]==1){
    		$this->model->UpdateUser($this->params);
    		$this->_redirect('/user/frontend/changeaccountinfo');
    	}else{
    		$this->model->UpdatePass($this->params);
    		$this->_redirect('/user/frontend/changepassword');
    	}
    	
    }
    public function changecompanyinfoAction()
    {
        $auth = Zend_Auth::getInstance();
        $id_company = $auth->getIdentity()->ID_COMPANY;
    	$data = $this->model->getCompanyInfo($id_company);
        $this->view->data = $data;
        $this->view->idCompany = $id_company;
    }
    public function changeaccountinfoAction()
    {
    	$this->model = new User_Model_User();
    	$auth = Zend_Auth::getInstance();
    	$username=$auth->getIdentity()->USERNAME;
    	$data=$this->model->FindByUser($username);
    	$this->view->data=$data;
    	$this->view->flag=1;
    }
    
    public function changepasswordAction()
    {
    	$this->model = new User_Model_User();
    	$auth = Zend_Auth::getInstance();
    	$username=$auth->getIdentity()->USERNAME;
    	$data=$this->model->FindByUser($username);
    	$this->view->data=$data;
    	$this->view->flag=2;
    }

    public function inputAction()
    {
    }


}

